import java.util.*;

public class Solution491 {
    public List<List<Integer>> findSubsequences(int[] nums) {
        Set<List<Integer>> ans=new HashSet<>();
        List<Integer> temp=new ArrayList<>();
        dfs(0,nums,temp,ans);
        return new ArrayList<>(ans);
    }

    private void dfs(int last, int[] nums, List<Integer> temp, Set<List<Integer>> ans) {
        if (temp.size()>=2){
            ans.add(new ArrayList<>(temp));
        }
        for (int i=last;i<nums.length;i++){
            if (temp.isEmpty() || nums[i]>=temp.get(temp.size()-1)){
                temp.add(nums[i]);
                dfs(i+1,nums,temp,ans);
                temp.remove(temp.size()-1);
            }
        }
    }

    public static void main(String[] args) {
        System.out.println(new Solution491().findSubsequences(new int[]{4,6,7,7}));
    }
}
